﻿using System;
using System.Collections;
using System.Collections.Generic;

namespace Marmat.Forms.Views
{
    namespace Grid
    {
        public class BandColumnCollection : IList
        {
            internal Band Band;
            private List<Column> List = new List<Column>();

            public BandColumnCollection(Band Band)
            {
                this.Band = Band;
            }

            void ICollection.CopyTo(Array array, int index)
            {
            }

            public int Count
            {
                get
                {
                    return this.List.Count;
                }
            }

            public bool IsSynchronized
            {
                get
                {
                    return false;
                }
            }

            public object SyncRoot
            {
                get
                {
                    return this.List;
                }
            }

            public IEnumerator GetEnumerator()
            {
                return this.List.GetEnumerator();
            }

            public void Add(Column Item)
            {
                IList list = this;
                list.Add(Item);
            }

            int IList.Add(object value)
            {
                Column Item = (Column)value;
                this.List.Add(Item);
                // Me.Band._Band.Columns.Add(Item.BandedGridColumn)
                return -1;
            }

            public void Clear()
            {
                this.List.Clear();
                this.Band._band.Columns.Clear();
            }

            public bool Contains(Column Item)
            {
                return this.Contains(Item);
            }

            bool IList.Contains(object value)
            {
                return this.List.Contains((Column)value);
            }

            public int IndexOf(Column Item)
            {
                return this.IndexOf(Item);
            }

            int IList.IndexOf(object value)
            {
                return this.List.IndexOf((Column)value);
            }

            public void Insert(int index, object value)
            {
                Column Item = (Column)value;
                this.List.Insert(index, Item);
                // Me.Band._Band.Columns.Insert(index, Item.BandedGridColumn)
            }

            bool IList.IsFixedSize
            {
                get
                {
                    return false;
                }
            }

            bool IList.IsReadOnly
            {
                get
                {
                    return false;
                }
            }

            public Column this[int index]
            {
                get
                {
                    return this.List[index];
                }
            }

            object IList.this[int index]
            {
                get => this.List[index];
                set => throw new NotImplementedException();
            }


            public void Remove(Column Item)
            {
                this.Remove(Item);
            }

            void IList.Remove(object value)
            {
                Column Item = (Column)value;
                this.List.Remove(Item);
                // Me.Band._Band.Columns.Remove(Item.BandedGridColumn)
            }

            public void RemoveAt(int index)
            {
                this.List.RemoveAt(index);
                this.Band._band.Columns.RemoveAt(index);
            }
        }
    }
}